$serverName = "SQLServerTrainingKitAlias"

$server = New-Object Microsoft.SqlServer.Management.Smo.Server($serverName)
$server.ConnectionContext.LoginSecure = $true
$server.ConnectionContext.Connect()

$sqlStoreConnection = New-Object Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection($server.ConnectionContext.SqlConnectionObject)

$dacstore = New-Object Microsoft.SqlServer.Management.Dac.DacStore($sqlStoreConnection)
$dacstore.add_DacActionStarted({Write-Host `nStarting at $(get-date) :: $_.Description})
$dacstore.add_DacActionFinished({Write-Host Completed at $(get-date) :: $_.Description})

if ($dacstore.DacInstances.Contains("CaseLoad")) 
{
    $dacstore.Unmanage("CaseLoad")
}
else
{
    Write-Host "The CaseLoad data-tier application was not found"
}

if ($dacstore.DacInstances.Contains("CaseTrack")) 
{
    $dacstore.Unmanage("CaseTrack")
}
else
{
    Write-Host "The CaseTrack data-tier application was not found"
}